import React from 'react'
import {Switch,Route,Redirect} from "react-router-dom"
function RouterView({routes}) {
    return (
        <Switch>
            {
                routes.length>0&&routes.map((v,i)=>{
                    return(
                        v.path?
                        <Route path={v.path} key={i} render={props=><v.component {...props} routes={v.children}></v.component>}></Route>
                        :<Redirect to={v.to} from={v.from} key={i}></Redirect>
                    )
                })
            }
        </Switch>
    )
}

export default RouterView
